package com.company.project.component.quartz.task;



import java.util.List;

import com.company.project.Application;
import com.company.project.Application2;
import com.company.project.component.quartz.QuartzManager;
import com.company.project.component.quartz.data.ScheduleJob;
import org.junit.runner.RunWith;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


/**
 * 
* @Description: TODO()
* @ClassName: Test
* @author lwb fzlwb@intretech.com
* @date 2017年8月14日 下午5:01:38
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application2.class)
public class Test
{

	@org.junit.Test
	public void test() throws SchedulerException, InterruptedException
	{
		ScheduleJob job = new ScheduleJob();
		job.setJobName("demo");
		job.setJobGroup("demo");
		job.setJobStatus(ScheduleJob.STATUS_RUNNING);
		job.setCronExpression("*/3 * * * * ?");
		job.setDescription("demo");
		job.setBeanClass(TaskTest.class.getName());
		job.setIsConcurrent(ScheduleJob.CONCURRENT_NOT);
		job.setMethodName("run");
		job.setSpringId("taskTest");
		
		QuartzManager.getInstance().addJob(job);
		

		job = new ScheduleJob();
		job.setJobName("test1");
		job.setJobGroup("demo");
		job.setJobStatus(ScheduleJob.STATUS_RUNNING);
		job.setCronExpression("*/3 * * * * ?");
		job.setDescription("test1");
		job.setBeanClass(TaskTest.class.getName());
		job.setIsConcurrent(ScheduleJob.CONCURRENT_NOT);
		job.setMethodName("run1");
		job.setSpringId("taskTest");
		
		QuartzManager.getInstance().addJob(job);
		
		List<ScheduleJob> list = QuartzManager.getInstance().getAllJob();
		System.out.println("job size:" + list.size());
		for(ScheduleJob sj : list)
		{
			System.out.println(sj.toString());
		}
		Thread.sleep(20000);
		QuartzManager.getInstance().pauseJob(job);
		System.out.println("pause job name:" + job.getJobName());
		Thread.sleep(50000);
		
	}


}
